﻿@{
    ViewBag.Title = "EditClass";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@model FileClassModel
<div class="row-fluid" style="margin-top: 20px">
    <div class="span24 span-first">
        <form class="form-horizontal" method="post" action="/Admin/FileManage/EditClass">
            <div class="control-group">
                <label class="control-label"><s>*</s>上级分类：</label>
                <div class="controls">
                    <div id="ParentClassName" style="width: 350px">
                        @Html.HiddenFor(x => x.ParentID)
                    </div>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>分类名称：</label>
                <div class="controls">
                    @Html.HiddenFor(x => x.ID)
                    @Html.TextBoxFor(x => x.ClassName, new { style = "width:350px" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"><s>*</s>排序：</label>
                <div class="controls">
                    @Html.TextBoxFor(x => x.Sort, new { style = "width:350px" })
                </div>
            </div>
            <hr>
            <div style="text-align: center">
                <button class="button button-primary" type="submit">提交</button>
                <button class="button" type="reset" onclick="parent.CloseWin()">取消</button>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    BUI.use(['bui/extensions/treepicker', 'bui/tree'], function (TreePicker, Tree) {
        var Select = BUI.Select;
        var data = eval('@Html.Raw(Model.FileClass)');
        //由于这个树，不显示根节点，所以可以不指定根节点
        var tree = new Tree.TreeList({
            nodes: data,
            //dirSelectable : false,//阻止树节点选中
            showLine: true //显示连接线
        });

        var picker = new TreePicker({
            width: '360',
            children: [tree] //配置picker内的列表
        });
        select = new Select.Select({
            render: '#ParentClassName',
            width: '360',
            picker: picker,
            forceFit: false, //不强迫列表跟选择器宽度一致
            valueField: '#ParentID'
        });
        select.render();
        tree.on('itemclick', function (ev) {
            if (ev.item.id == $('#ID').val())
                return false;
        });

        //picker.render();
    });
</script>

